package project.parser.ast.exps.op.binary;

import project.environments.DynamicEnv;
import project.environments.StaticEnv;
import project.environments.Value;
import project.parser.ast.exps.Exp;
import project.parser.ast.types.Type;
import project.parser.ast.util.EvalUtil;
import project.parser.ast.util.TypecheckUtil;
import project.parser.ast.values.BoolValue;
import project.parser.tokenizer.TokenType;

public class Gth extends BinaryOp {
	public Gth(Exp left, Exp right) {
		super(left, right);
	}

	@Override
	protected String opToString() {
		return TokenType.GTH.toString();
	}

	@Override
	public Type typecheck(StaticEnv senv) {
		return TypecheckUtil.checkCompIntOp(senv, left, right);
	}

	@Override
	public Value evaluate(DynamicEnv denv) {
		int[] args = EvalUtil.evalIntArgs(denv, left, right);
		return new BoolValue(args[0] > args[1]);
	}

}
